 

package com.zdkj.subway.rca.controller;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.zdkj.common.core.util.R;
import com.zdkj.common.log.annotation.SysLog;
import com.zdkj.common.security.service.PigxUser;
import com.zdkj.common.security.util.SecurityUtils;
import com.zdkj.subway.rca.dto.in.UserDto;
import com.zdkj.subway.rca.entity.SwCkOthenTicketRevenueManagementTmp;
import com.zdkj.subway.rca.service.SwCkOthenTicketRevenueManagementTmpService;
import com.zdkj.subway.rca.util.UserUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * 报表调账-其他运营商票务收入管理表
 *
 * @author stw
 * @date 2020-10-31 08:14:55
 */
@RestController
@AllArgsConstructor
@RequestMapping("/swckothenticketrevenuemanagement" )
@Api(value = "swckothenticketrevenuemanagement", tags = "报表调账-其他运营商票务收入管理表管理")
public class SwCkOthenTicketRevenueManagementController {

    @Autowired
    private SwCkOthenTicketRevenueManagementTmpService swCkOthenTicketRevenueManagementTmpService;


    /**
     * 导入预处理查询
     * @return
     */
    @ApiOperation(value = "导入预处理查询", notes = "导入预处理查询")
    @GetMapping("/listPreprocessing" )
    @PreAuthorize("@pms.hasPermission('sw_ck_othen_ticket_revenue_management_import')")
    public R listPreprocessing() {
        PigxUser user = SecurityUtils.getUser();
        SwCkOthenTicketRevenueManagementTmp swCkOthenTicketRevenueManagementTmp = new  SwCkOthenTicketRevenueManagementTmp();
        swCkOthenTicketRevenueManagementTmp.setCreatorId(user.getId());
        return R.ok(swCkOthenTicketRevenueManagementTmpService.list(Wrappers.query(swCkOthenTicketRevenueManagementTmp)));
    }
    /**
     * 预处理确认
     * @return
     * @throws Exception
     */
    @ApiOperation(value = "预处理确认", notes = "预处理确认")
    //@SysLog("其他运营商票务收入管理预处理确认")
    @PostMapping({ "/saveBatchOk" })
    //@PreAuthorize("@pms.hasPermission('sw_ck_othen_ticket_revenue_management_import')")
    public R saveBatchOk() throws Exception {
        PigxUser pigxUser = SecurityUtils.getUser();
        UserDto user = new UserDto();
        if(pigxUser == null){
            user = UserUtil.userDto();
        }else {
            user = UserUtil.pigxUser();
        }
        this.swCkOthenTicketRevenueManagementTmpService.saveBatchWithExcelOk(user);
        return R.ok(true);
    }
    /**
     * 预处理取消
     * @return
     * @throws Exception
     */
    @ApiOperation(value = "预处理取消", notes = "预处理取消")
    @SysLog("其他运营商票务收入管理预处理取消")
    @PostMapping({ "/saveBatchCancel" })
    @PreAuthorize("@pms.hasPermission('sw_ck_othen_ticket_revenue_management_import')")
    public R saveBatchCancel() throws Exception {
        PigxUser user = SecurityUtils.getUser();
        this.swCkOthenTicketRevenueManagementTmpService.saveBatchWithExcelCancel(user.getId());
        return R.ok(true);
    }
}
